package ControlLayer;
import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 *
 * @author gartner
 */
public class CtrSupplier {
    

         public ArrayList getAllSuppliers()
    {
      IFDBSupplier dbSupplier = new DBSupplier();
      ArrayList allSuppliers = new ArrayList();
      allSuppliers = dbSupplier.getAllSuppliers(false);
      return allSuppliers;
    }

    public Supplier findSupplier(int supplierID) 
    {
	IFDBSupplier dbSupplier = new DBSupplier();
	return dbSupplier.findSupplier(supplierID, true);
    }

    public Supplier searchSupplierID(int supplierID)
    {
        IFDBSupplier dbSupplier = new DBSupplier();
        return dbSupplier.searchSupplierID(supplierID, true);
    }
    
    public Supplier searchSupplierName(String name)
    {
        IFDBSupplier dbSupplier = new DBSupplier();
        return dbSupplier.searchSupplierName(name, true);
    }

    
    public void insertProduct(Product pro) 
    {
	IFDBProduct dbPro = new DBProduct();
        dbPro.insertProduct(pro);

     }
    
    public void deleteProduct(int productID)
    {
        IFDBProduct dbPro = new DBProduct();
        dbPro.deleteProduct(productID);
    }
    
    public void deleteSupplier(int supplierID)
    {
        IFDBSupplier dbSup = new DBSupplier();
        dbSup.deleteSupplier(supplierID);
    }
    
     public void updateSupplier(int supplierID, String name, String address,int phoneNo )
    
    {
        IFDBSupplier dbSup = new DBSupplier();
	
        Supplier supp = new Supplier();
        
	supp.setName(name);
        supp.setAddress(address);
        supp.setPhoneNo(phoneNo);
        supp.setSupID(supplierID);
	dbSup.updateSupplier(supp);
    }  

     
         public void insertSupplier(Supplier sup) 
    {
	IFDBSupplier dbSup = new DBSupplier();
        dbSup.insertSupplier(sup);
     }
         
          public int getMaxID()
    {
        IFDBSupplier dbSup = new DBSupplier();
        int id = dbSup.MaxID();
        return id;
    }
     
          public void setSupplier(Supplier supplier)
          {
              this.setSupplier(supplier);
          }
          
     
}